package com.example.controller;

import com.example.service.userService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
public class MyController {

    @Autowired
    userService userService;

    @GetMapping("/user/asyncTest")
    @ResponseBody
    public ResponseEntity<String> asyncTest(){
        long beginTime = System.currentTimeMillis();
        for (int i = 0; i < 4; i++) {
            userService.sayHello();
        }
        long duringTime = System.currentTimeMillis()-beginTime;
        System.out.println("执行结束,消耗时间："+duringTime);
        return ResponseEntity.ok(""+duringTime);
    }

    @GetMapping({"/","/index"})
    public String tiIndex(){
        return "index";
    }
}
